package ro.upt.ac.cstaicu.instrumentation.classadapters;


import java.util.ArrayList;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;

import ro.upt.ac.cstaicu.instrumentation.methodadapters.IMMethodAdapter;

public class IMMethodsFilterCA extends IMClassAdapter {

	private ArrayList<String> desiredMethods;
	private IMMethodAdapter adapter = null;
	
	public IMMethodsFilterCA(ClassVisitor cv, ArrayList<String> desiredMethods) {
		super(cv);
		this.desiredMethods = desiredMethods;
	}
	
	protected MethodVisitor getMethodAdapter(MethodVisitor visitor,
			String className, String methodName) {
		if (desiredMethods.contains(methodName)) {
			adapter = new IMMethodAdapter(visitor, className, methodName);
			adapters.put(methodName, adapter);
			return adapter;
		} else {
			return visitor;
		}
	}
	
}
